import requests

url = "http://www.baidu.com"

# 装成浏览器
headers = {
    'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/131.0.0.0'
}

# 添加请求头
response = requests.get(url,headers=headers)
print(response.content.decode())